package com.lyc;

import java.util.Arrays;

public class code1 {
    //递推公式：
    /*public static void main(String[] args) {
        print(12312);
    }

    public static void print(int n)
    {
        if(n<10) {
            System.out.println(n % 10);
            return;
        }
       print(n/10);
        System.out.println(n%10);
    }*/

  /*  public static void main(String[] args) {

        System.out.println(sum(10));
    }

    public static int sum(int n)
    {
        if(n==1) {
        return 1;
    }
else
    return n+sum(n-1);

    }*/

    /*public static void main(String[] args) {

            System.out.println(sum(123));
        }
        public static int sum(int n){
        if(n<10) {
            return n;
        }
       else
        return n%10+sum(n/10);
        }*/
    //斐波那契数列
    //递归方法
/*public static void main(String[] args) {
    System.out.println(fblq(5));
}

public static int fblq(int n)
{
    if(n==0||n==1)
        return 1;
    else
        return fblq(n-1)+fblq(n-2);
}*/
    //减少时间复杂度
  /*  public static void main(String[] args) {
        Fblq(5);
    }
public static void Fblq(int n)
{
    int a1=1;
    int a2=1;
    int fblq=0;
    for(int i=3;i<=n;i++)
    {
        fblq=a1+a2;
        a2=fblq;
        a1=a2;
    }
    System.out.println(fblq);
    return ;
}*/

   /* public static void main(String[] args) {
        int [] arr={11,22,33,44};
        for (int x: arr) {
            System.out.print(x+" ");
        }
        System.out.println();
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }*/
/*   public static void main(String[] args) {
       int []arr={11,33,22,55,44};
       System.out.println(Arrays.toString(arr));
     Arrays.sort(arr);
       System.out.println(Arrays.toString(arr));
   }*/

    //冒泡排序函数
    /*public static void main(String[] args) {
        int []arr={22,33,11,55,44};
        Bubble(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void Bubble(int []arr1)
    {
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1.length-1-i; j++) {
                int temp=0;
                if(arr1[j]>arr1[j+1]) {
                    temp = arr1[j];
                    arr1[j] = arr1[j + 1];
                    arr1[j + 1] = temp;
                }
            }
        }
    }*/

    //数组逆序
    public static void main(String[] args) {
        int arr[]={1,2,3,4};
        resever(arr);
        System.out.println(Arrays.toString(arr));
    }

    public static void resever(int arr[]) {
        int left=0;
        int right=arr.length-1;
        while(left<right)
        {
            int tmep=arr[left];
            arr[left]=arr[right];
            arr[right]=tmep;
            left++;
            right--;
        }

    }
}
